﻿@using DIS.Infrastructure.Entities.Entity;
@using DIS.Infrastructure.Entities.DTO;
@{
    ViewBag.Title = "GetSummaryDetail";
    Layout = "~/Views/Shared/_Layout.cshtml";
    Project project = ViewBag.project;
    List<SummaryDetailDTO> list = ViewBag.data;
    FinancialPeriod fp = ViewBag.financialPeriod;
    decimal totalmoney = ViewBag.totalmoney == null ? 0 : ViewBag.totalmoney;
    int totalDays = ViewBag.totalDays == null ? 0 : ViewBag.totalDays;
    
}

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#D6D6D6">
    <tr>
        <td height="19" background="/content/img/tbg.gif" bgcolor="#E7E7E7">
            <table width="96%" border="0" cellspacing="1" cellpadding="1">
                <tr>
                    <td style="padding-left: 10px;">
                        <b><strong>汇总明细</strong></b>
                    </td>
                    <td align="right">
                        <b><strong><a href="/SummaryData/GetAllSummary">汇总列表</a></strong></b>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td align="right"><a href="/SummaryData/SummaryExcel?year=@fp.Year&month=@fp.Month&projectId=@project.Id">导出Excel</a></td></tr>
    <tr>
        <td align="center" valign="top" bgcolor="#FFFFFF">
            <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1">
                <tr>
                    <td colspan="4" style="font-size: 20px; font-weight: bold">
                        @(project.ProjectName)项目组差旅费汇总表(@(fp.Year)年@(fp.Month)月)
                    </td>
                </tr>
                <tr>
                    <td>
                        报销人：
                    </td>
                    <td>
                        部门：
                    </td>
                    <td>
                        总人天数：@totalDays
                    </td>
                    <td>
                        差旅费总计：@totalmoney
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td align="center" valign="top" bgcolor="#FFFFFF">
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#D6D6D6">
                <tr>
                    <td>
                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
                            <thead>
                                <tr bgcolor="#FBFCE2">
                                    <td width="5%" align="center" rowspan="2">
                                        序号
                                    </td>
                                    <td width="5%" align="center" rowspan="2">
                                        姓名
                                    </td>
                                    <td width="15%" align="center" colspan="3">
                                        市内交通费
                                    </td>
                                    <td width="15%" align="center" colspan="3">
                                        在途费用<br />
                                        (不含机票)
                                    </td>
                                    <td width="8%" align="center" colspan="3">
                                        公务杂费
                                    </td>
                                    <td width="15%" align="center" colspan="3">
                                        住宿费
                                    </td>
                                    <td width="8%" align="center" colspan="3">
                                        汽油费
                                    </td>
                                    <td width="5%" align="center" rowspan="2">
                                        发票数
                                    </td>
                                    <td width="5%" align="center" rowspan="2">
                                        小计
                                    </td>
                                    <td width="5%" align="center" rowspan="2">
                                        出差伙<br />
                                        食补助
                                    </td>
                                    <td width="5%" align="center" rowspan="2">
                                        合计
                                    </td>
                                    <td width="5%" align="center" rowspan="2">
                                        报销单号
                                    </td>
                                    <td width="10%" align="center" rowspan="2">
                                        项目编号
                                    </td>
                                </tr>
                                <tr bgcolor="#FBFCE2">
                                    <td>
                                        金额
                                    </td>
                                    <td>
                                        发票数
                                    </td>
                                    <td>
                                        小计
                                    </td>
                                    <td>
                                        金额
                                    </td>
                                    <td>
                                        发票数
                                    </td>
                                    <td>
                                        小计
                                    </td>
                                    <td>
                                        金额
                                    </td>
                                    <td>
                                        发票数
                                    </td>
                                    <td>
                                        小计
                                    </td>
                                    <td>
                                        金额
                                    </td>
                                    <td>
                                        发票数
                                    </td>
                                    <td>
                                        小计
                                    </td>
                                    <td>
                                        金额
                                    </td>
                                    <td>
                                        发票数
                                    </td>
                                    <td>
                                        小计
                                    </td>
                                </tr>
                            </thead>
                            <tbody>
                                @{
                                    decimal ttaxifee=0;
                                    int ttaxicount=0;
                                     decimal thotelfee=0;
                                     int thotelcount = 0;
                                     decimal tlongfee = 0;
                                     int tlongcount = 0;
                                     decimal tallowance = 0;
                                     decimal tfee=0;
                                     int tcount=0;
                                     decimal tlastfee=0;
                                    if(list!=null&&list.Count>0)
                                    {
                                        int j=1;
                                        foreach(var item in list)
                                        {
                                            decimal taxiMoney = item.cityTaxi == null ? 0 : item.cityTaxi.TaxiFee;
                                            int taxiInvoice = item.cityTaxi == null ? 0 : item.cityTaxi.InvoiceCount;
                                            ttaxifee = ttaxifee + taxiMoney;
                                            ttaxicount = ttaxicount + taxiInvoice;
                                            decimal hotelMonty = item.hotelFee == null ? 0 : item.hotelFee.TotalFee;
                                            int hotelInvoice = item.hotelFee == null ? 0 : item.hotelFee.InvoiceCount;
                                            
                                            thotelfee = thotelfee + hotelMonty;
                                            thotelcount = thotelcount + hotelInvoice;
                                            decimal longMonty = item.longFee == null ? 0 : item.longFee.TotalFee;
                                            int longInvoice = item.longFee == null ? 0 : item.longFee.InvoiceCount;
                                            decimal allowanceMoney = item.longFee == null ? 0 : item.longFee.AllowanceMoney;
                                            tlongfee = tlongfee + longMonty;
                                            tlongcount = tlongcount + longInvoice;
                                            tallowance = tallowance + allowanceMoney;

                                            tfee = tfee + item.totalFee;
                                            tcount = tcount + item.totalCount;
                                            tlastfee = tlastfee + item.lasttotalFee;
                                            
                                        <tr bgcolor="#FFFFFF" align="center">
                                            <td>
                                                @j
                                            </td>
                                            <td>@item.userName
                                            </td>
                                            <td>@taxiMoney
                                            </td>
                                            <td>@taxiInvoice
                                            </td>
                                            <td>@taxiMoney
                                            </td>
                                            <td>@longMonty
                                            </td>
                                            <td>@longInvoice
                                            </td>
                                            <td>@longMonty
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>@hotelMonty
                                            </td>
                                            <td>@hotelInvoice
                                            </td>
                                            <td>@hotelMonty
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>@item.totalCount
                                            </td>
                                            <td>@item.totalFee
                                            </td>
                                            <td>@allowanceMoney
                                            </td>
                                            <td>@item.lasttotalFee
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>@project.ProjectCode
                                            </td>
                                        </tr>
                                            j++;
                                        }
                                    }
                                }
                            </tbody>
                            <tfoot>
                            <tr bgcolor="#FBFCE2" align="center">
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td><font><b>合计</b></font>
                                            </td>
                                            <td>@ttaxifee
                                            </td>
                                            <td>@ttaxicount
                                            </td>
                                            <td>@ttaxifee
                                            </td>
                                            <td>@tlongfee
                                            </td>
                                            <td>@tlongcount
                                            </td>
                                            <td>@tlongfee
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>@thotelfee
                                            </td>
                                            <td>@tlongcount
                                            </td>
                                            <td>@thotelfee
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>@tcount
                                            </td>
                                            <td>@tfee
                                            </td>
                                            <td>@tallowance 
                                            </td>
                                            <td>@tlastfee
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                            </td>
                                        </tr>
                                        <tr bgcolor="#FFFFFF" align="center" class="hover">
                    <td align="left" colspan="23">
                        <b><font style="color: red">说明：本表作为每月报销差旅费附件。</font></b>
                    </td>
                </tr>
                            </tfoot>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

</table>

